<template>
  <div class="work-record-header">
    <el-row>
      <!-- 搜索部分 -->
      <el-form :inline="true" :model="formInline" label-width="100px">
        <el-form-item label="Check Time">
          <el-date-picker
            v-model="trackinTime"
            :default-time="['00:00:00','23:59:59']"
            type="daterange"
            format="yyyy-MM-dd HH:mm:ss"
            value-format="yyyy-MM-dd HH:mm:ss"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          />
        </el-form-item>
        <el-form-item label="Processflow ">
          <el-input
            v-model="formInline.Processflow "
            placeholder
            clearable
        /></el-form-item>
        <el-form-item label="Handler">
          <el-input
            v-model="formInline.Handler"
            placeholder
            clearable
        /></el-form-item>
        <el-form-item label="产品型号">
          <el-input
            v-model="formInline.productName"
            placeholder
            clearable
        /></el-form-item>
        <el-form-item label="OutputType">
          <el-select v-model="formInline.OutputType" clearable filterable>
            <el-option
              v-for="i in outputTypeList"
              :key="i.id"
              :label="i.name"
              :value="i.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="Type">
          <el-select v-model="formInline.Type" clearable filterable>
            <el-option value="0" label="表格" />
            <el-option value="1" label="图形" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="doSearch">{{
            $t("search")
          }}</el-button>
        </el-form-item>
      </el-form>
    </el-row>
  </div>
</template>
<script>
import workRecordApi from '@/api/dashboardManager/binAnalysis'
import enumApi from '@/api/system/enum'
import { clearNull } from '@/utils/myTools'
export default {
  name: 'OutPut',
  props: {
    listQuery: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      show: false,
      outputTypeList: [],
      formInline: {},
      trackinTime: null,
      rules: {
        trackinTime: [
          {
            type: 'date',
            required: true,
            message: '请输入时间段',
            trigger: 'change'
          }
        ]
      }
    }
  },
  created() {
    this.getOutputTypeList()
    this.formInline = { ...this.$route.query }
  },
  methods: {
    // 点击查询
    doSearch() {
      if (this.trackinTime !== null && this.trackinTime.length > 0) {
        this.formInline.StartTime = this.trackinTime[0]
        this.formInline.EndTime = this.trackinTime[1]
      } else {
        this.formInline.StartTime = null
        this.formInline.EndTime = null
      }
      const obj = clearNull(this.formInline)
      workRecordApi.searchInfo({ ...obj, ...this.listQuery }).then((res) => {
        this.$emit('initTable', res.data)
        this.$emit('initdataInfo', res)
      })
    },
    getOutputTypeList() {
      enumApi.getList({ enumName: 'outputTypeEnum' }).then((res) => {
        this.outputTypeList = res.data
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.el-row {
  padding: 10px;
  background-color: #fff;
}
.el-input{
  width: 150px;
}
.el-select {
  width: 150px;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}
</style>
